package com.example.demo;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    // 定义水果价格
    private static final int APPLE_PRICE = 8;
    private static final int BERRY_PRICE = 13;
    private static final int MANGUO_PRICE = 20;

    //封装顾客A,B计算总价方法
    public static Double calculatePrice(int appleWeight, int berryWeight, int manGuoWeight) {
        //计算总价
        double totalPrice = APPLE_PRICE * appleWeight + BERRY_PRICE * berryWeight + MANGUO_PRICE * manGuoWeight;
        return totalPrice;
    }

    // 顾客C购买的水果，草莓打8折
    public static Double calculatePrice2(int appleWeight, int berryWeight, int manGuoWeight) {
        double totalPrice = (APPLE_PRICE * appleWeight) + ((BERRY_PRICE * 0.8) * berryWeight) + (MANGUO_PRICE * manGuoWeight);
        return totalPrice;
    }

    // 顾客D购买的水果，购物满100减10
    public static Double calculatePrice3(int appleWeight, int berryWeight, int manGuoWeight) {
        double totalPriceBeforeDiscount = calculatePrice(appleWeight, berryWeight, manGuoWeight);
        if (totalPriceBeforeDiscount >= 100) {
            return totalPriceBeforeDiscount - 10;
        } else {
            return totalPriceBeforeDiscount;
        }
    }

    public static void main(String[] args) {
        //自定义顾客A购买斤数
        double allPriceA = calculatePrice(3, 5, 0);
        System.out.println("顾客A一共花了" + allPriceA + "元");

        //自定义顾客B购买斤数
        double allPriceB = calculatePrice(3, 5, 4);
        System.out.println("顾客B一共花了" + allPriceB + "元");

        // 顾客C购买的水果总价
        double allPriceC = calculatePrice2(3, 5, 4);
        System.out.println("顾客C一共花了: " + allPriceC + "元");

        // 顾客D购买的水果总价
        double allPriceD = calculatePrice3(3, 5, 4);
        System.out.println("顾客D一共花了: " + allPriceD + "元");
        //SpringApplication.run(DemoApplication.class, args);
    }
}
